#include "StdAfx.h"
#include "TemplateList.h"

namespace SpikingNeuronLib
{
	// Private Members -------------------------------------------------------------------------------------------

	TemplateList^ TemplateList::GetDistinctPatterns()
	{
		Dictionary<String^, Pattern^>^ patternDictionary = gcnew Dictionary<String^, Pattern^>();
		for each (Pattern^ pattern in _patterns)
		{
			String^ key = pattern->ToString();
			if (!patternDictionary->ContainsKey(key))
			{
				patternDictionary->Add(key, pattern);
			}
		}

		return gcnew TemplateList(System::Linq::Enumerable::ToList(patternDictionary->Values));
	}

	// Public Members -------------------------------------------------------------------------------------------

	TemplateList::TemplateList(void)
	{
		_patterns = gcnew List<Pattern^>();
	}

	TemplateList::TemplateList(List<Pattern^>^ patterns)
	{
		_patterns = patterns;
	}

	TemplateList::TemplateList(array<Pattern^>^ patterns)
	{
		_patterns = gcnew List<Pattern^>(patterns);
	}

	void TemplateList::Add(Pattern^ pattern)
	{
		_patterns->Add(pattern);
	}
}
